#pragma once
#include "DataType.h"
#include "BaseSample.h"
#include "Image3D.h"
#include <string>

typedef enum {
	IA_TAG_NODE_MSG_TYPE_REQUEST=0,
	IA_TAG_NODE_MSG_TYPE_REPLY
} ENodeMsgTypes;

typedef enum {
	IA_TAG_NODE_MSG_DATA_TYPE_TEXT = 0,
	IA_TAG_NODE_MSG_DATA_TYPE_BINARY,
	IA_TAG_NODE_MSG_DATA_TYPE_IMAGE,
	IA_TAG_NODE_MSG_DATA_TYPE_IMAGE3D,
} ENodeMsgDataTypes;

/**
 * @file CNodeMsg.h
 *
 * @brief This class defines the interaction message within serveral clients(computers)
 *				in the case of distributed system
 *
 * @author cygia.com
 * Contact: lance.liao@cygia.com
 *
 */
class CNodeMsg :
	public CDataType, public CBaseSample
{
public:
	CBaseSample* CreateInstance();

public:
	CNodeMsg();
	~CNodeMsg();

public:
	// You can put anything in "Message", for other items '\n' is not expected
	ENodeMsgTypes MsgType;
	ENodeMsgDataTypes MsgDataType;
	int StatusCode;

	std::string SrcAddr;			// Station: IP+Port
	std::string SubSrcAddr;		// Unit

	std::string DstAddr;
	std::string SubDstAddr;

	std::string Command;
	std::string Message;
	
	unsigned int BinDataLen;
	unsigned char* pBinData;
	
public:
	std::string Flatten();
	int Expand(std::string flattenStr);

	int FillWithImage3D(CImage3D* pimg3D);
	int ExtraceImage3D(CImage3D* pImage3D);

	CNodeMsg* Copy();
	int SetBinDataByString(std::string str);
	std::string ToString();

};

